package com.java8feature.java8action.parallelStream;

import java.util.stream.Stream;

/**
 * @description:todo
 * @auth yangzhiwei
 * @date 2021-06-12 15:28
 */

public class ParallelSum {
    public static long parallelSum(long n) {
        return Stream.iterate(1L, i -> i + 1)
                .limit(n)
                .parallel()
                // 进行每项操作前加上这个基础值
                .reduce(5L,Long::sum);
    }

    public static void main(String[] args) {
        System.out.println(parallelSum(4));
    }
}
